<template>
  <view class="content">
    <text class="title">{{ store.title }}</text>

    <view class="counter-section">
      <text class="count">当前计数: {{ store.count }}</text>
      <text class="double-count">双倍计数: {{ store.doubleCount }}</text>
      <button @click="store.increment()"
        class="w-4/5 bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-lg shadow-md active:shadow-sm transition-all">增加计数</button>
    </view>

    <view class="title-section">
      <input v-model="newTitle" placeholder="输入新标题" />
      <button @click="updateTitle"
        class="w-4/5 bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-lg shadow-md active:shadow-sm transition-all">更新标题</button>
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useIndexStore } from '@/store/index'

const store = useIndexStore()
const newTitle = ref('')

const updateTitle = () => {
  if (newTitle.value) {
    store.setTitle(newTitle.value)
    newTitle.value = ''
  }
}
</script>

<style>
.content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.title {
  font-size: 36rpx;
  margin-bottom: 30px;
}

.counter-section, .title-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  margin-bottom: 30px;
}

.count, .double-count {
  font-size: 32rpx;
  margin-bottom: 10px;
}

button {
  margin: 10px 0;
}

input {
  border: 1px solid #ddd;
  padding: 8px;
  width: 80%;
  border-radius: 4px;
}
</style>
